package sjtu.pirate.report.simple;

import java.io.IOException;
import java.util.Date;
import sjtu.pirate.analyzer.PirateAnalyzer;
import sjtu.pirate.report.ReportTemplate;
import sjtu.pirate.util.FormHelper;

import biz.source_code.miniTemplator.MiniTemplator.TemplateSyntaxException;
/**
 * @author wilbur.ma@qq.com
 * @date 2011.05.31
 */
public class HostIndexTemplate extends ReportTemplate {
	public HostIndexTemplate(String templateFile, String reportDir, PirateAnalyzer analyzer) 
			throws TemplateSyntaxException, IOException {
		super(templateFile, reportDir, "/index.html", analyzer);
	}
	
	@Override
	protected void setTemplateParams() {
		setVar("current_date", new Date().toString());
		setVar("sites_num", analyzer.getResults().size());
		for (String s : analyzer.getResults().keySet()) {
			setVar("a_href", "detail/index.html#" + FormHelper.buildHostID(s));
			setVar("a_value", s);
			setVar("forms_num", analyzer.getResults().get(s).size());
			setVar("fail_forms_num", analyzer.getFailFormsNum(s));
			addBlock("indexBlock");
		}
	}
}
